home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_kdelibs.idb / usr / freeware / kde / include / kmsgbox.h.z / kmsgbox.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  6.0 KB  |  174 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 1997 Alexander Sanda (alex@darkstar.ping.at)
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public License
  15.     along with this library; see the file COPYING.LIB.  If not, write to
  16.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.     Boston, MA 02111-1307, USA.
  18. */
  19. /*
  20.  * $Id: kmsgbox.h,v 1.7 1998/01/03 19:47:30 kulow Exp $
  21.  *
  22.  * $Log: kmsgbox.h,v $
  23.  * Revision 1.7  1998/01/03 19:47:30  kulow
  24.  * changed the defaults for yesNo and co. It's no longer "Yes" and co, but
  25.  * 0 to enable translation in case.
  26.  * This is source and binary compatible. It's just, that it will behave
  27.  * differently after recompiling (as far I understood the C++ language ;)
  28.  *
  29.  * Revision 1.6  1997/11/04 17:48:51  kulow
  30.  * hmm, gcc accepts QPixmap & icon = 0, Sparc CC won't. So I made it .. = QPixmap()
  31.  *
  32.  * Revision 1.5  1997/10/21 20:45:03  kulow
  33.  * removed all NULLs and replaced it with 0L or "".
  34.  * There are some left in mediatool, but this is not C++
  35.  *
  36.  * Revision 1.4  1997/10/16 11:15:27  torben
  37.  * Kalle: Copyright headers
  38.  * kdoctoolbar removed
  39.  *
  40.  * Revision 1.3  1997/07/24 21:06:07  kalle
  41.  * Kalle:
  42.  * KToolBar upgraded to newtoolbar 0.6
  43.  * KTreeList has rubberbanding now
  44.  * Patches for SGI
  45.  *
  46.  * Revision 1.2  1997/05/08 22:53:20  kalle
  47.  * Kalle:
  48.  * KPixmap gone for good
  49.  * Eliminated static objects from KApplication and HTML-Widget
  50.  *
  51.  * Revision 1.1.1.1  1997/04/13 14:42:42  cvsuser
  52.  * Source imported
  53.  *
  54.  * Revision 1.1.1.1  1997/04/09 00:28:09  cvsuser
  55.  * Sources imported
  56.  *
  57.  * Revision 1.1  1997/03/15 22:41:21  kalle
  58.  * Initial revision
  59.  *
  60.  * Revision 1.3.2.1  1997/01/10 19:48:32  alex
  61.  * public release 0.1
  62.  *
  63.  * Revision 1.3  1997/01/10 19:44:33  alex
  64.  * *** empty log message ***
  65.  *
  66.  * Revision 1.2.4.1  1997/01/10 16:46:33  alex
  67.  * rel 0.1a, not public
  68.  *
  69.  * Revision 1.2  1997/01/10 13:05:52  alex
  70.  * *** empty log message ***
  71.  *
  72.  * Revision 1.1.1.1  1997/01/10 13:05:21  alex
  73.  * imported
  74.  *
  75.  */
  76.  
  77. // kmsgbox.h
  78.  
  79. #ifndef _KMSGBOX_H_
  80. #define _KMSGBOX_H_
  81.  
  82. #include <qobjdefs.h>
  83. #include <qdialog.h>
  84. #include <qpushbt.h>
  85. #include <qlabel.h>
  86. #include <qframe.h>
  87. #include <qpixmap.h>
  88.  
  89.  
  90. /// KMsgBox
  91. /** A message box API for the KDE project. KMsgBox provides a Windows - lookalike message- or
  92.  error box with icons and up to 4 configurable buttons.
  93.  */
  94.  
  95. class KMsgBox : public QDialog
  96. {
  97.     Q_OBJECT
  98. public:
  99.  
  100.     enum {INFORMATION = 1, EXCLAMATION = 2, STOP = 4, QUESTION = 8};
  101.     enum {DB_FIRST = 16, DB_SECOND = 32, DB_THIRD = 64, DB_FOURTH = 128};
  102.     
  103.     /// Constructor
  104.     /** The generic constructor for a KMsgBox Widget. All parameters have a default value of 0.
  105.      @Doc:
  106.      \begin{itemize}
  107.      \item { \tt The parent widget }
  108.      \item { \tt A caption (title) for the message box. }
  109.      \item { \tt a message string. The default alignment is centered. The string may contain
  110.      newline characters.}
  111.      \item { \tt Flags: This parameter is responsible for several behaviour options of the
  112.      message box. See below for valid constans for this parameter.}
  113.      \item { \tt Up to 4 button strings (b1text to b4text). You have to specify at least b1text.
  114.      Unspecified buttons will not appear in the message box, therefore you can control the
  115.      number of buttons in the box.}
  116.      \end{itemize}
  117.      */
  118.     KMsgBox(QWidget *parent = 0, const char *caption = 0, const char *message = 0, int flags = INFORMATION,
  119.             const char *b1text = 0, const char *b2text = 0, const char *b3text = 0, const char *b4text = 0);
  120.  
  121.     // the default destructor - only for some compilers
  122.     ~KMsgBox();
  123.     /// yesNo
  124.     /** A static member function. Can be used to create simple message boxes with a
  125.      single function call. This box has 2 buttons which default to "Yes" and "No". The icon
  126.      shows a question mark. The appearance can be manipulated with the {\bf type} parameter.
  127.      */
  128.     
  129.     static int yesNo(QWidget *parent = 0, const char *caption = 0, const char *message = 0, int type = 0,
  130.                      const char *yes = 0, const char *no = 0);
  131.  
  132.     /// yesNoCancel
  133.     /** A static member function for creating a three-way message box. The box has three
  134.      buttons (defaulting to "Yes", "No" and "Cancel") and a question-mark icon. The {\bf type}
  135.      Parameter can be used to change the default behaviour.
  136.      */
  137.     
  138.     static int yesNoCancel(QWidget *parent = 0, const char *caption = 0, const char *message = 0, int type = 0,
  139.                            const char *yes = 0, const char *no = 0, const char *cancel = 0);
  140.  
  141.     /// message
  142.     /** A static member function. Creates a simple message box with only one button ("Ok")
  143.      and a information-icon. The icon can be changed by using another value for the {\bf type}
  144.      parameter.
  145.      */
  146.     
  147.     static int message(QWidget *parent = 0, const char *caption = 0, const char *message = 0, int type = 0,
  148.                        const char *btext = 0);
  149.  
  150.  
  151. private:
  152.     enum {B_SPACING = 10, B_WIDTH = 80};
  153.     QLabel      *msg, *picture;
  154.     QPushButton *b1, *b2, *b3, *b4;
  155.     QFrame      *f1;
  156.     int nr_buttons;
  157.     int         w, h, h1, text_offset;
  158.     void        calcOptimalSize();
  159.     void        resizeEvent(QResizeEvent *);
  160.  
  161.     void        initMe(const char *caption, const char *message, const char *b1text,
  162.                        const char *b2text, const char *b3text, const char *b4text,
  163.                        const QPixmap & icon = QPixmap());
  164.  
  165. public slots:
  166.     void        b1Pressed();
  167.     void        b2Pressed();
  168.     void        b3Pressed();
  169.     void        b4Pressed();
  170. };
  171.  
  172. #endif
  173.  
  174.